Standalone: add a default global timezone setting - #36400
Conversation
|
🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷 Introduction for new contributors...
PR commands & links...
|
|
Nice one thanks @mlutfy ! I think the general shape is good but I have a few quibbles about language and how "default" works... (incoming) |
| 'name' => 'standalone_timezone_default', | ||
| 'group' => 'standaloneusers', | ||
| 'type' => 'String', | ||
| 'default' => date_default_timezone_get(), |
There was a problem hiding this comment.
I would avoid this kind of dynamic default. There's lots of ways it gets confusing:
- you change the server timezone and its not reflected because this default has been cached
- you go to the settings page and it shows as set to the specific timezone of your server, then the server timezone changes and you go back and its something else
- same thing except you saved on the settings page so the server value literal was saved to civi db, now the server changes and it's not reflected
- you have any kind of horizontally scaled deployment with different server timezones
All this is to say, I think it might be better to have an empty default, with a placeholder like "- use server timezone -"?
| 'title' => E::ts('Default Timezone'), | ||
| 'is_domain' => 1, | ||
| 'is_contact' => 0, | ||
| 'description' => E::ts('Default timezone for anonymous users and for users using the default timezone.'), |
There was a problem hiding this comment.
| 'title' => E::ts('Default Timezone'), | |
| 'is_domain' => 1, | |
| 'is_contact' => 0, | |
| 'description' => E::ts('Default timezone for anonymous users and for users using the default timezone.'), | |
| 'title' => E::ts('System Timezone'), | |
| 'is_domain' => 1, | |
| 'is_contact' => 0, | |
| 'description' => E::ts('Timezone to use for dates and times - unless overridden at user-level.'), |
I think "default" is confusing here, because there's a default value for Default timezone; and the default value of User timezone is "use the default timezone" and...
| 'default' => date_default_timezone_get(), | ||
| 'html_type' => 'select', | ||
| 'html_attributes' => [ | ||
| 'class' => 'huge crm-select2', |
There was a problem hiding this comment.
Maybe something like this for the placeholder?
| 'class' => 'huge crm-select2', | |
| 'class' => 'huge crm-select2', | |
| 'placeholder' => E::ts('Use server timezone - currently %1', [1 => date_default_timezone_get()]), |
| use CRM_Standaloneusers_ExtensionUtil as E; | ||
|
|
||
| return [ | ||
| 'standalone_timezone_default' => [ |
There was a problem hiding this comment.
maybe also we can use settings_pages key to put this on a different page from Login settings. I'm not sure whether localization or date (the latter is date formats atm)?
| // Fallback in case the setting is not yet set during the initial upgrade | ||
| // (or cache flush) |
There was a problem hiding this comment.
shouldn't this be...
| // Fallback in case the setting is not yet set during the initial upgrade | |
| // (or cache flush) | |
| // Global fallback if no timezone specified at user level |
?
Overview
Adds a default timezone setting for Standalone, so that it does not rely on the timezone of the server.
Before
Relies on the default PHP timezone, which is often UTC.
After
New setting so that it can be set by the admin.
Technical Details
For anonymous users, I tested things such as submitting a FormBuilder form that creates an activity, and the default time seemed OK.
Comments
cc @ufundo